<html>
<head><meta charset="utf-8"><title>async unsafe fn · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html">async unsafe fn</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="169901125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901125">(Jul 08 2019 at 20:15)</a>:</h4>
<p>Maybe we ought to discuss the async unsafe fn question? cc <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>, <span class="user-mention" data-user-id="126931">@centril</span>, <span class="user-mention" data-user-id="203289">@boats</span></p>



<a name="169901174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901174">(Jul 08 2019 at 20:16)</a>:</h4>
<p>Whether to gate or not gate?</p>



<a name="169901179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901179">(Jul 08 2019 at 20:16)</a>:</h4>
<p>Or the design?</p>



<a name="169901193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901193">(Jul 08 2019 at 20:16)</a>:</h4>
<p>I am referring <a href="https://github.com/rust-lang/rust/issues/62149#issuecomment-509374290" target="_blank" title="https://github.com/rust-lang/rust/issues/62149#issuecomment-509374290">to <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>'s comment</a></p>



<a name="169901298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901298">(Jul 08 2019 at 20:18)</a>:</h4>
<p>We did the same for <code>const unsafe fn</code> so I don't think it's surprising and moreover it wasn't mentioned in the RFC or report at all</p>



<a name="169901372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901372">(Jul 08 2019 at 20:19)</a>:</h4>
<p>The basic concern is that <code>async unsafe fn</code> makes it unsafe to <em>produce</em> the closure but not to <em>await</em> it, but almost certainly the unsafety arises because of something the function does and not the mere act of <em>producing</em> the closure.</p>



<a name="169901392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901392">(Jul 08 2019 at 20:19)</a>:</h4>
<p>I suppose you can always "desugar" to </p>
<div class="codehilite"><pre><span></span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Future</span><span class="o">&lt;</span><span class="p">..</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">async</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="169901487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901487">(Jul 08 2019 at 20:20)</a>:</h4>
<p>i.e., to get today's semantics</p>



<a name="169901556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901556">(Jul 08 2019 at 20:22)</a>:</h4>
<p>I think the part of <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>'s comment that caught my eye was this:</p>
<blockquote>
<p>Yet another feature gate will contribute to the impression of async/await as unfinished.</p>
</blockquote>
<p>which is perhaps a more basic disagreement. </p>
<p>Still, I feel like <code>async unsafe fn</code> will be a relatively unusual thing..?</p>



<a name="169901617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901617">(Jul 08 2019 at 20:22)</a>:</h4>
<p>I think the impression is true so there's no need to pretend it is not</p>



<a name="169901639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901639">(Jul 08 2019 at 20:23)</a>:</h4>
<p>There's an honesty to that; and I don't think gating <code>async unsafe fn</code> changes it particularly</p>



<a name="169901672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901672">(Jul 08 2019 at 20:23)</a>:</h4>
<p><code>const fn</code> is also radically more unfinished, yet we shipped it</p>



<a name="169901748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901748">(Jul 08 2019 at 20:24)</a>:</h4>
<blockquote>
<p>I think the impression is true so there's no need to pretend it is not</p>
</blockquote>
<p>I also feel that way :)</p>



<a name="169901773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169901773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169901773">(Jul 08 2019 at 20:25)</a>:</h4>
<p>(If nothing else, the fact that it doesn't work in traits feels incomplete, though I understand that this is an oversimplification.)</p>



<a name="169902819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169902819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169902819">(Jul 08 2019 at 20:38)</a>:</h4>
<p>I believe that <code>const unsafe fn</code> is significantly different from <code>unsafe async fn</code> in that the interaction between <code>unsafe</code> and <code>const</code> is actually unclear</p>



<a name="169902827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169902827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169902827">(Jul 08 2019 at 20:38)</a>:</h4>
<p>there are actually key things about what unsafe code is allowed in <code>const fn</code> that had not yet been determined</p>



<a name="169902889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169902889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169902889">(Jul 08 2019 at 20:39)</a>:</h4>
<p>I don't believe the same is true for <code>async unsafe fn</code>-- I don't know of any outstanding questions around the interaction between <code>async</code> and <code>unsafe</code>, and the current behavior is, I believe, easily justified by the desugared understanding of what <code>async fn</code> means.</p>



<a name="169902978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169902978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169902978">(Jul 08 2019 at 20:40)</a>:</h4>
<blockquote>
<p>I think the impression is true so there's no need to pretend it is not</p>
</blockquote>



<a name="169903024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903024">(Jul 08 2019 at 20:41)</a>:</h4>
<p>I'm not sure what the point you're making here is. We've put a lot of work into making sure that <code>async</code>/<code>await</code> provides a positive end-user experience despite some currently fundamental limitations.</p>



<a name="169903113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903113">(Jul 08 2019 at 20:42)</a>:</h4>
<p>Those limitations are necessary, understandable and easily justified once users understand the desugared model of <code>async fn</code>.</p>



<a name="169903322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903322">(Jul 08 2019 at 20:45)</a>:</h4>
<p>Blocking basic things like <code>unsafe</code> from working, however, isn't a fundamental or difficult problem in any way, is not interesting to consider from a user's perspective, the workarounds don't teach the user more about the system than they would have known otherwise (unlike the lessons to be learned from attempting to use <code>async fn</code> in traits), and overall I think this sort of limitation will strike users more as missing polish than interesting open design considerations.</p>



<a name="169903355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903355">(Jul 08 2019 at 20:45)</a>:</h4>
<p>In that, I think it's more similar to bad error messages than it is to not being able to use <code>async fn</code> in traits.</p>



<a name="169903651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903651">(Jul 08 2019 at 20:49)</a>:</h4>
<blockquote>
<p>I believe that const unsafe fn is significantly different from unsafe async fn in that the interaction between unsafe and const is actually unclear</p>
</blockquote>
<p>It wasn't that unclear actually, there was just some hesitation on my end but we didn't change that much aside from not allowing some things to be <code>const</code>.</p>
<blockquote>
<p>[...], and the current behavior is, I believe, easily justified by the desugared understanding of what async fn means.</p>
</blockquote>
<p>This assumes a certain desugaring and it focuses on explanation by desugaring. One could imagine a different one which would render <code>.await</code> the point at which you have to use <code>unsafe { ... }</code> which at least from my view is saner on initial inspection.</p>



<a name="169903752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903752">(Jul 08 2019 at 20:50)</a>:</h4>
<p>No, I don't believe that would be correct</p>



<a name="169903767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903767">(Jul 08 2019 at 20:50)</a>:</h4>
<p>(using <code>unsafe</code> where the future is awaited, rather than constructed)</p>



<a name="169903805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903805">(Jul 08 2019 at 20:51)</a>:</h4>
<p>For one, await isn't the only way to poll or manipulate a future. The moment at which the future is constructed is the moment at which you must ensure all invariants are satisfied</p>



<a name="169903818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903818">(Jul 08 2019 at 20:51)</a>:</h4>
<p>this is true today with <code>unsafe fn foo() -&gt; impl Future</code></p>



<a name="169903977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169903977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169903977">(Jul 08 2019 at 20:53)</a>:</h4>
<blockquote>
<p>For one, await isn't the only way to poll or manipulate a future. The moment at which the future is constructed is the moment at which you must ensure all invariants are satisfied</p>
</blockquote>
<p>an interesting observation.</p>



<a name="169904000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904000">(Jul 08 2019 at 20:54)</a>:</h4>
<p>I feel like it happens a plenty that the "contract" on an unsafe fn constraints future actions of what you can do w/ the return value</p>



<a name="169904048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904048">(Jul 08 2019 at 20:54)</a>:</h4>
<p>(and past actions of what you can have done leading up to this)</p>



<a name="169904088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904088">(Jul 08 2019 at 20:54)</a>:</h4>
<p>Yeah, I do this all the time with things that are e.g. implementations of safe <code>Visitor</code> traits that have unsafe behavior and so are unsafe to construct, yet the trait methods themselves are safe</p>



<a name="169904143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904143">(Jul 08 2019 at 20:55)</a>:</h4>
<p>it was one of the reasons I pushed back against <span class="user-mention" data-user-id="120791">@RalfJ</span> 's idea way back when that literal <code>unsafe { ... }</code> blocks should have an effect on the way the code inside them was optimized</p>



<a name="169904233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904233">(Jul 08 2019 at 20:56)</a>:</h4>
<p>we'll leave that part aside :P</p>



<a name="169904252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904252">(Jul 08 2019 at 20:56)</a>:</h4>
<p>(there is clearly still some kind of "scope" of unsafety that ought to be observed...)</p>



<a name="169904264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904264">(Jul 08 2019 at 20:57)</a>:</h4>
<p>but it's neither here nor there :) well, it is <em>relevant</em>, in that this is the concern</p>



<a name="169904274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904274">(Jul 08 2019 at 20:57)</a>:</h4>
<p>but you are correct that this same thing arises frequently in Rust</p>



<a name="169904299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904299">(Jul 08 2019 at 20:57)</a>:</h4>
<p>Right, I don't think the situation with <code>async unsafe fn</code> is unique or interesting, either of which might suggest that we should deliberate</p>



<a name="169904367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904367">(Jul 08 2019 at 20:58)</a>:</h4>
<p>I could vaguely imagine some kind of system where you can do <code>-&gt; impl unsafe Future</code> to indicate that invoke the trait methods is unsafe, which I guess is more in the direction of what <span class="user-mention" data-user-id="126931">@centril</span> is imagining.</p>



<a name="169904383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904383">(Jul 08 2019 at 20:58)</a>:</h4>
<p>right, with an <code>unsafe poll</code></p>



<a name="169904388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904388">(Jul 08 2019 at 20:58)</a>:</h4>
<p>But it seems... pretty far off to me to even contemplate. I guess it depends if we get some notion of a <code>const</code> trait bound that can be applied</p>



<a name="169904400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904400">(Jul 08 2019 at 20:59)</a>:</h4>
<p>(the alternative would be a <code>impl UnsafeFuture</code> hack, where that is a distinct trait)</p>



<a name="169904405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904405">(Jul 08 2019 at 20:59)</a>:</h4>
<p>which requires some kind of abstraction over whether or not a trait impl is <code>unsafe</code> and a way to be generic over <code>unsafe</code>ty of a trait implementor</p>



<a name="169904412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904412">(Jul 08 2019 at 20:59)</a>:</h4>
<blockquote>
<p>I guess it depends if we get some notion of a <code>const</code> trait bound that can be applied</p>
</blockquote>
<p>this is specifically the thing I had in mind when I said "seems like it can't hurt to take some time and think about it"</p>



<a name="169904415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904415">(Jul 08 2019 at 20:59)</a>:</h4>
<p>the same pattern can be applied to the visitor i mentioned above</p>



<a name="169904446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904446">(Jul 08 2019 at 20:59)</a>:</h4>
<p>This is all astronomically far away from reality, though</p>



<a name="169904812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904812">(Jul 08 2019 at 21:04)</a>:</h4>
<blockquote>
<p>Yeah, I do this all the time with things that are e.g. implementations of safe Visitor traits that have unsafe behavior and so are unsafe to construct, yet the trait methods themselves are safe</p>
</blockquote>
<p>Things like that does surprise me; that's not my idea of how scoping of <code>unsafe</code> works but I suppose <code>unsafe</code> is very "build your own" in terms of how you define scoping.</p>
<blockquote>
<p>For one, await isn't the only way to poll or manipulate a future.</p>
</blockquote>
<p>A good point; ostensibly you can imagine <code>trait UnsafeFuture: Future {}</code> which is checked on calls to <code>.poll</code> through lang items to change this but costs are increasing now... (i.e. "hack" in <span class="user-mention" data-user-id="116009">@nikomatsakis</span>'s sense but the trait itself can be forever-unstable)</p>
<blockquote>
<p>this is true today with unsafe fn foo() -&gt; impl Future</p>
</blockquote>
<p>Well the unsafety could be before the future is returned in that case so it feels different.</p>
<blockquote>
<p>The moment at which the future is constructed is the moment at which you must ensure all invariants are satisfied</p>
</blockquote>
<p>Any particular examples of when it would be problematic for <code>async unsafe fn</code> otherwise?</p>
<blockquote>
<p>This is all astronomically far away from reality, though</p>
</blockquote>
<p>That's not my impression from talking with Oliver's re. <code>const fn</code> and trait bounds.</p>



<a name="169904820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904820">(Jul 08 2019 at 21:04)</a>:</h4>
<p>I can go either way I guess. I feel like the current semantics are pretty reasonable given the state of Rust (and, indeed, the desugaring). But I also don't mind waiting a bit to talk over the possible ways we might handle this, it seems like a bit of a corner case. </p>
<p>I also like the strategy of using a "reference desugaring" (whether or not that is how it is implemented) to help handle corner cases in the semantics.</p>



<a name="169904975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/169904975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#169904975">(Jul 08 2019 at 21:06)</a>:</h4>
<blockquote>
<p>I also like the strategy of using a "reference desugaring" (whether or not that is how it is implemented) to help handle corner cases in the semantics.</p>
</blockquote>
<p>I like this as well when you can actually do it but this can also be a trap... one that I think I laid for myself with <code>if a &amp;&amp; let b = c {</code></p>



<a name="170455896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170455896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170455896">(Jul 09 2019 at 14:06)</a>:</h4>
<p>I do not believe there is a viable alternative for <code>async unsafe fn</code> to what is currently implemented and I don't think it should be blocked from stabilization.</p>



<a name="170456046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170456046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170456046">(Jul 09 2019 at 14:08)</a>:</h4>
<blockquote>
<p>A good point; ostensibly you can imagine trait UnsafeFuture: Future {} which is checked on calls to .poll through lang items to change this but costs are increasing now... (i.e. "hack" in</p>
</blockquote>



<a name="170456145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170456145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170456145">(Jul 09 2019 at 14:09)</a>:</h4>
<p>This doesn't make sense to me, these types would still implement <code>Future</code> and thus have a safe poll method (unless you meant adding a supertrait to <em>future</em>, rather than what you wrote, but even this is pretty contrived and complicated)</p>



<a name="170456325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170456325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170456325">(Jul 09 2019 at 14:11)</a>:</h4>
<p>Yeah it has to be a supertrait</p>



<a name="170456345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170456345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170456345">(Jul 09 2019 at 14:11)</a>:</h4>
<p>But that route feels "not worth it" to me</p>



<a name="170456690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170456690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170456690">(Jul 09 2019 at 14:15)</a>:</h4>
<p>yea its a lot of machiner and I agree with taylor that this represents a very normal pattern (imposing invariants on the constructor you expect to be true during the lifetime of the object)</p>



<a name="170456699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170456699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170456699">(Jul 09 2019 at 14:15)</a>:</h4>
<p>literally this is how <code>Vec::from_raw_parts</code> works!</p>



<a name="170457172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170457172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170457172">(Jul 09 2019 at 14:20)</a>:</h4>
<p>I also don't know what invariants you could be upholding at an await point, either.. I guess if it involved some shared state passed in through the function call.</p>



<a name="170457300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170457300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170457300">(Jul 09 2019 at 14:22)</a>:</h4>
<p>Yea after these few minutes of reflection, not only do I think an alternative design is overcomplicated, I think it would be wrong. In practice, the only place to uphold invariants on an async fn is at the call site.</p>



<a name="170457954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170457954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170457954">(Jul 09 2019 at 14:27)</a>:</h4>
<p>I mean I think you may well have to check things at the await site -- i.e., that a raw pointer is still valid.</p>



<a name="170458023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170458023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170458023">(Jul 09 2019 at 14:28)</a>:</h4>
<p>But I do think it's "the normal pattern" in Rust today to denote such things <em>primarily</em> at the creation site (from-raw-parts being a good example)</p>



<a name="170458042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170458042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170458042">(Jul 09 2019 at 14:28)</a>:</h4>
<p>thats what i mean by shared state passed in through the call</p>



<a name="170458049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170458049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170458049">(Jul 09 2019 at 14:28)</a>:</h4>
<p>And a lot of times those invariants <em>are</em> solely* enforced at the creation site in any case</p>



<a name="170458082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170458082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170458082">(Jul 09 2019 at 14:28)</a>:</h4>
<p>e.g., "this must be a raw pointer that represents an owned box" or "this index must be within bounds for that thing" or something</p>



<a name="170458113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170458113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170458113">(Jul 09 2019 at 14:29)</a>:</h4>
<p>(I guess it'd be interesting to see some examples in practice)</p>



<a name="170458504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170458504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170458504">(Jul 09 2019 at 14:32)</a>:</h4>
<p>It's also true for <code>Vec::from_raw_parts</code> for example, that you can't invalidate the pointer you pass to it through another API later on.</p>



<a name="170458696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170458696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170458696">(Jul 09 2019 at 14:34)</a>:</h4>
<p>I don't even think this rises to the level of the interaction between <code>Pin</code> and <code>Drop</code>, where we unfortunately have to uphold invariants in a less than ideal place (pin projection) because we can't uphold them in the best place (the drop impl).</p>



<a name="170470449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170470449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170470449">(Jul 09 2019 at 16:57)</a>:</h4>
<blockquote>
<p>It's also true for <code>Vec::from_raw_parts</code> for example, that you can't invalidate the pointer you pass to it through another API later on.</p>
</blockquote>
<p>right, it represents a (logical) ownership transfer</p>



<a name="170516982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20unsafe%20fn/near/170516982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20unsafe.20fn.html#170516982">(Jul 10 2019 at 06:52)</a>:</h4>
<blockquote>
<p>it was one of the reasons I pushed back against <span class="user-mention silent" data-user-id="120791">RalfJ</span> 's idea way back when that literal <code>unsafe { ... }</code> blocks should have an effect on the way the code inside them was optimized</p>
</blockquote>
<p>I wouldnt even say it was my idea, I think I got it from Niko's blog post. ;) But yes I entertained it for a while. Mostly out of necessity. But with Stacked Borrows it does not seem needed any more and then I definitely prefer not to do it (i.e., I prefer to leave <code>unsafe</code> a purely syntactic marker).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>